home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / chapter10 / threed.java < prev    next >
Text File  |  1995-12-31  |  589b  |  29 lines

  1. /* Allocating often used (and comparatively hard to */
  2. /* calculate) values in static variables            */
  3.  
  4. class threed {
  5.  
  6.     static float sines[] = new float[360];
  7.     static float cosines[] = new float[360];
  8.     
  9.     static {
  10.       double gd;
  11.       for (int g=0;g<360;++g) {
  12.        gd = (double)g * 0.01745;
  13.        sines[g] = (float)Math.sin(gd);
  14.        cosines[g] = (float)Math.cos(gd);
  15.        }
  16.     }
  17.     }
  18.  
  19. class threedtest {
  20.  
  21.     public static void main (String arg[]) {
  22.     
  23. //    threed t = new threed();
  24.     
  25.     System.out.println(threed.cosines[0]);
  26. //    System.out.println(t.cosines[0]);
  27.     }
  28.     }
  29.